layui.use(top.layuiuse,
    function () {
        var layer = layui.layer;
        var watermark = layui.watermark;
        var $ = layui.jquery;
        var upload = layui.upload;
        var index = layui.index;
        var formDesigner = layui.formDesigner;
        var form = layui.form;
        var kaPublic = layui.kaPublic;
        var render;
        var kaAjax = layui.kaAjax;
        var kaBgUrl = layui.kaBgUrl;
        //公共
        var bodyUrl = kaPublic.initBodySetUp();
        //加载水印
        loadingWatermark(watermark)
        var kaAjaxFormData = {
            "id": bodyUrl.id
        };
        var url = "";
        if(!isNaN(parseInt(bodyUrl.id))){
            url = "getFormRenderingById" + kaAjaxFormData.id;
        } else {
            url = "getFormRenderingById";
        }
        kaAjax.ajax(kaBgUrl.url(url), function (rs) {
            if (rs.code == 200) { 
                var localStorageLayuiFormMain = rs.data.form;
                var javaScriptFilePath = localStorageLayuiFormMain.javaScriptFilePath;
                var javaScriptType = localStorageLayuiFormMain.javaScriptType;
                var localStorageLayuiForm = rs.data.val;
                if (localStorageLayuiForm !== undefined || localStorageLayuiForm !== null) {
                    render = formDesigner.render({
                        elem: '#formDesignerView',
                        formId: javaScriptFilePath,
                        data: localStorageLayuiForm,
                        viewOrDesign: true,
                        formDefaultButton: true,
                        formDefaultButtonId: javaScriptFilePath
                        //formData: {"textarea_1":"123","input_2":"123","password_3":"123"}
                    });
                    layui.kaForm.submit(javaScriptFilePath, javaScriptFilePath, javaScriptFilePath, { "type": javaScriptType, "path": javaScriptFilePath});
                }
            }
        }, kaAjaxFormData);
        
    }
)

function getSubmitData() {
    var data = $('#formDesignerView').form[0].serialize();
    console.log(data);
    return data;
}